<?php use_javascript('jquery-1.3.2.min.js') ?>
<?php use_helper ('Form','Javascript','Object') ?>


<table width="100%" border="0" cellspacing="0" cellpadding="0"  class="heading_table">
    <tr>
        <td height="30"><span class="heading">Utility Bills for the Month: </span></td>
        <td align="right" height="30" valign="bottom">
        <span style="float:right"><?php echo image_tag('icon_addRight.jpg', 'width="2"', 'height="22"')?></span>
        <?php echo link_to('Prepare new Bill', 'Billing/addOfficerBill', array('class'=>'addNew')) ;?>
        </td>
    </tr>
    
</table> 
 

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="datagrid">

<!-- TODO: SORT BY STATION-->             

    <tr>
        <th style="text-align:left;">Rank/Name</th>
        <th style="text-align:left;">Station</th>
        <th style="text-align:left;">Consumer No.</th>
        <th style="text-align:left;">Total Bill</th>
        <th style="text-align:left;">Status</th>
        <th style="text-align:left;">Operation</th>
    </tr>

 
<?php 
if (count($bills)): ?>
<?php 
foreach ($bills as $j => $bill) : ?>
    <tr>
        <td align="left"><?php echo link_to($bill->getOccupant()->getRank().' '.$bill->getOccupant()->getName(), 'Billing/detailBill?id='.Utility::EncryptQueryString($bill->getId())); ?> </td>
        <td align="left">&nbsp;<?php echo $bill->getStation(); ?></td>
        <td align="left">&nbsp;<?php echo $bill->getBuilding()->getConsumerNo(); ?></td>
        <td align="left">&nbsp;<?php echo $bill->getGrandTotal(); ?></td>
        <td align="center"><?php echo Constant::GetRecordStatusTitle($bill->getStatus()); ?></td>
        <td align="center"><?php echo $bill->getUpdatedAt('d-M-Y'); ?>
        <td align="right" class="edit">
        <?php echo link_to('&nbsp;','Building/edit?id='.Utility::EncryptQueryString($bill->getId()),array('title'=>'Edit', 'class' => 'edit'))?>
        <?php echo link_to('&nbsp;','Building/delete?id='.Utility::EncryptQueryString($bill->getId()), array('confirm'=>'Are you sure you want to Delete this?', 'title'=>'Delete', 'class' => 'delete')); ?>
        </td>
    </tr>

<?php endforeach; ?>
    <tr>
   		<td class="last">&nbsp;</td>
    </tr>
<?php else:?>

<tr>
	<td colspan="6" style="background:none; text-align:center;"><?php echo Constant::RECORD_NOT_FOUND; ?></td>
</tr>

<?php endif; ?>
</table>